package com.cjst.util;

import java.lang.reflect.Field;
import java.util.HashMap;

public class ResultMap {
	private HashMap<String, String> data = new HashMap<String, String>();

	public ResultMap(Object obj) {
		if (obj == null) {
			data = null;
		} else {

			try {
				Field[] declaredFields = obj.getClass().getDeclaredFields();
				for (Field field : declaredFields) {
					field.setAccessible(true);
					if(field.get(obj)!=null) {
						data.put(field.getName(), field.get(obj).toString());
					}else {
						data.put(field.getName(), "");
					}
				}
			} catch (Exception e) {

			}
		}

	}
	
	public void put(String key,Object obj) {
		data.put(key, obj.toString());
	}
	
	public HashMap<String,String> getData(){
		return data;
	}

}
